/**
 * Title: AccountActivity.java
 * Description:
 * Copyright: Copyright (c) 2008
 * Company:深圳彩讯科技有限公司
 * Author 罗旭东 (hi@luoxudong.com)
 * Date 2013-11-24 上午11:33:37
 * Version 1.0
 */
package com.luoxudong.phonenumber.ui.activities;

import com.luoxudong.phonenumber.R;
import com.luoxudong.phonenumber.ui.common.listener.OnClickAvoidForceListener;
import com.luoxudong.phonenumber.ui.widgets.titlebar.ITitleBarOnClickListener;
import com.luoxudong.phonenumber.ui.widgets.titlebar.TitleBarView;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;

/** 
 * ClassName: AccountActivity
 * Description:我的菜单tab
 * Create by 罗旭东
 * Date 2013-11-24 上午11:33:37
 */
public class AccountActivity extends AbsSubActivity{
	private TitleBarView titleBarView = null;
	private LinearLayout favoriteLayout = null;
	private LinearLayout browserHistoryLayout = null;
	private LinearLayout myOrderLayout = null;
	private LinearLayout telRecordLayout = null;
	private LinearLayout feedBackLayout = null;
	private ImageButton logoutIbtn = null;
	
	@Override
	protected int getContentViewLayoutResId() {
		return R.layout.account_layout;
	}

	@Override
	protected void onCreateFindView(Bundle savedInstanceState) {
		titleBarView = (TitleBarView)findViewById(R.id.title_bar);
		favoriteLayout = (LinearLayout)findViewById(R.id.rl_myfavorite);
		browserHistoryLayout = (LinearLayout)findViewById(R.id.rl_browser_history);
		myOrderLayout = (LinearLayout)findViewById(R.id.rl_my_order);
		telRecordLayout = (LinearLayout)findViewById(R.id.rl_tel_record);
		feedBackLayout = (LinearLayout)findViewById(R.id.rl_feedback);
		logoutIbtn = (ImageButton)findViewById(R.id.ibtn_logout);
		
		titleBarView.setTitle(R.string.account);
	}

	@Override
	protected void onCreateAddListener(Bundle savedInstanceState) {
		titleBarView.setTitleBarOnClickListener(onTitleClickListener);
		favoriteLayout.setOnClickListener(onClickListener);
		browserHistoryLayout.setOnClickListener(onClickListener);
		myOrderLayout.setOnClickListener(onClickListener);
		telRecordLayout.setOnClickListener(onClickListener);
		feedBackLayout.setOnClickListener(onClickListener);
		logoutIbtn.setOnClickListener(onClickListener);
	}

	@Override
	protected void onCreateInitData(Bundle savedInstanceState) {
		
	}

	@Override
	protected void onCreateTaskLoadData() {
		
	}

	@Override
	protected void onCreateTaskAddView() {
		
	}

	@Override
	protected void refreshUI(Object obj) {
		
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN)
		{
			exitApp();
			return true;
			
		}
		return super.onKeyDown(keyCode, event);
	}
	
	public void onBackPressed() {
		exitApp();
	};

	private ITitleBarOnClickListener onTitleClickListener = new ITitleBarOnClickListener() {
		
		@Override
		public void onRightClick(View v) {
			// TODO Auto-generated method stub
			
		}
		
		@Override
		public void onLeftClick(View v) {
			// TODO Auto-generated method stub
			
		}
	};
	
	private OnClickAvoidForceListener onClickListener = new OnClickAvoidForceListener() {
		
		@Override
		public void onClickAvoidForce(View v) {
			Intent intent = null;
			switch (v.getId()) {
			case R.id.rl_myfavorite:
				intent = new Intent(AccountActivity.this, MyFavoriteActivity.class);
				startActivity(intent);
				break;
			case R.id.rl_browser_history:
				intent = new Intent(AccountActivity.this, BrowserHistoryActivity.class);
				startActivity(intent);
				break;
			case R.id.rl_my_order:
				intent = new Intent(AccountActivity.this, MyOrderActivity.class);
				startActivity(intent);
				break;
			case R.id.rl_tel_record:
				intent = new Intent(AccountActivity.this, TelRecordActivity.class);
				startActivity(intent);
				break;
			case R.id.rl_feedback:
				intent = new Intent(AccountActivity.this, FeedbackActivity.class);
				startActivity(intent);
				break;
			case R.id.ibtn_logout:
				break;
			default:
				break;
			}
		}
	};
}
